package com.apes.fn.scm.internal.help.service.voucher;

import com.apes.fn.scm.internal.help.model.InternalHelpReturnApproval;
import com.apes.fn.scm.internal.help.model.InternalHelpReturnApprovalItem;
import com.apes.fn.scm.internal.help.service.voucher.inner.InnerHelpReturnVoucherService;
import com.apes.fn.scm.internal.help.service.voucher.inner.StoreInnerHelpReturnVoucherService;
import com.apes.fn.scm.internal.help.service.voucher.retail.*;
import com.apes.fn.scm.internal.help.service.voucher.sale.SaleAutReturnVoucherService;
import com.apes.fn.scm.internal.help.service.voucher.sale.SaleOutHelpReturnVoucherService;
import com.apes.fn.scm.internal.help.service.voucher.sale.SalePaintReturnVoucherService;
import com.apes.fn.scm.internal.help.service.voucher.sale.SalePlanOutHelpReturnVoucherService;
import com.apes.fn.scm.retailReturn.RetailReturn;
import com.apes.fn.scm.retailReturn.RetailReturnItem;
import com.apes.scm.sal.saleOrder.SaleOrderItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * 零售退货代理类
 *
 * @Author wuq
 * @Date 2021-10-13
 */
@Service
public class ReturnAccountService {

    @Autowired
    private CrossICReturnVoucherService crossICReturnVoucherService;
    @Autowired
    private RetailPaintReturnVoucherService retailPaintReturnVoucherService;
    @Autowired
    private RetailOutHelpReturnVoucherService retailOutHelpReturnVoucherService;
    @Autowired
    private ServerPlanPaintReturnVoucherService serverPlanPaintReturnVoucherService;
    @Autowired
    private ServerOutHelpReturnVoucherService serverOutHelpReturnVoucherService;
    @Autowired
    private InnerHelpReturnVoucherService innerHelpReturnVoucherService;
    @Autowired
    private SaleOutHelpReturnVoucherService saleOutHelpReturnVoucherService;
    @Autowired
    private SalePlanOutHelpReturnVoucherService salePlanOutHelpReturnVoucherService;
    @Autowired
    private SaleAutReturnVoucherService saleAutReturnVoucherService;
    @Autowired
    private SalePaintReturnVoucherService salePaintReturnVoucherService;
    @Autowired
    private StoreInnerHelpReturnVoucherService storeInnerHelpReturnVoucherService;
    @Autowired
    private EntrustLossReturnVoucherService entrustLossReturnVoucherService;
    @Autowired
    private AnnualAuditReturnVoucherService annualAuditReturnVoucherService;
    @Autowired
    private UnitClientReturnVoucherService unitClientReturnVoucherService;

    // 退异业
    public void returnCrossIC(RetailReturn retailReturn) {
        crossICReturnVoucherService.process(retailReturn);
    }

    // 退零售单产生的油漆
    public void returnRetailPaint(RetailReturn retailReturn) {
        retailPaintReturnVoucherService.process(retailReturn);
    }

    // 退代销带安
    public void returnRetailOutHelp(RetailReturn retailReturn) {
        if (Objects.equals("annualAudit", retailReturn.getSaleOrder().getOrderType())) {
            // 年审单独处理
            annualAuditReturnVoucherService.process(retailReturn);
        } else {
            retailOutHelpReturnVoucherService.process(retailReturn);
        }
    }

    // 退经销带安（外协部分）
    public void returnServerOutHelp(List<RetailReturnItem> items) {
        serverOutHelpReturnVoucherService.process(items);
    }

    // 退服务方案带安部分
    public void returnServerOutHelp(Map<String, Object> param) {
        serverOutHelpReturnVoucherService.process(param);
    }

    // 同公司油漆
    public void returnServerPaint(List<RetailReturnItem> items) {
        serverPlanPaintReturnVoucherService.process(items);
    }

    // 内协退货单分销退回凭证
    public void returnInnerHelp(InternalHelpReturnApproval internalHelpReturnApproval) {
        innerHelpReturnVoucherService.process(internalHelpReturnApproval);
    }

    // 退分销单代外协
    public void returnSaleOutHelp(Map<SaleOrderItem, InternalHelpReturnApprovalItem> param) {
        saleOutHelpReturnVoucherService.process(param);
    }

    // 退分销经销外协
    public void returnSalePlanOutHelp(Map<SaleOrderItem, InternalHelpReturnApprovalItem> param) {
        salePlanOutHelpReturnVoucherService.process(param);
    }

    // 退分销油漆商品
    public void returnSalePaint(Map<SaleOrderItem, InternalHelpReturnApprovalItem> param) {
        salePaintReturnVoucherService.process(param);
    }

    // 退分销服务商品
    public void returnSaleAut(Map<SaleOrderItem, InternalHelpReturnApprovalItem> param) {
        saleAutReturnVoucherService.process(param);
    }

    // 门店内协部分退货
    public void returnStoreInnerHelp(InternalHelpReturnApproval internalHelpReturnApproval) {
        storeInnerHelpReturnVoucherService.process(internalHelpReturnApproval);
    }

    public void returnEntrustLoss(RetailReturn retailReturn) {
        entrustLossReturnVoucherService.process(retailReturn);
    }

    // 退单位客户挂账部分
    public void returnUnitClient(RetailReturn retailReturn) {
        unitClientReturnVoucherService.process(retailReturn);
    }
}
